package cl.android.accessdata;

import static android.provider.BaseColumns._ID;
import static cl.android.accessdata.ConstantsToken.NAME;
import static cl.android.accessdata.ConstantsToken.NAME2;
import static cl.android.accessdata.ConstantsToken.TABLE_NAME;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Esta clase contiene lo necesario para crear una base de datos propia de la aplicacion de android.
 * @author Renew21
 */
public class TokenData extends SQLiteOpenHelper {
	
	private static final String DATABASE_NAME = "token_data.db";
	private static final int DATABASE_VERSION = 1;
	
	

	/** Create a helper object for the Events database */
	public TokenData(Context ctx) {
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		//String createTable = "CREATE TABLE market ( id interger.., time..., name...)";
		
		db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + NAME + " TEXT, "+ NAME2 + " INTEGER)");
		db.execSQL("INSERT INTO "+ TABLE_NAME +" ("+NAME+","+NAME2+") VALUES ('-', 0)");
		
		
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
		
		
	}
}